<!DOCTYPE html><html class="theme-next pisces use-motion" lang="zh-CN"><head><meta name="generator" content="Hexo 3.9.0"><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=2"><meta name="theme-color" content="#222"><link rel="apple-touch-icon" sizes="180x180" href="/images/icons/favicon-48.png?v=6.7.0"><link rel="icon" type="image/png" sizes="32x32" href="/images/icons/favicon-32.png?v=6.7.0"><link rel="icon" type="image/png" sizes="16x16" href="/images/icons/favicon-16.png?v=6.7.0"><link rel="mask-icon" href="/images/icons/logo.svg?v=6.7.0" color="#222"><link rel="alternate" href="/atom.xml" title="菠菜眾長" type="application/atom+xml"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><link href="/lib/fancybox/source/jquery.fancybox.css" rel="stylesheet" type="text/css"><link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css"><link href="/css/main.css?v=6.7.0" rel="stylesheet" type="text/css"><script type="text/javascript" id="hexo.configurations">var NexT=window.NexT||{},CONFIG={root:"/",scheme:"Pisces",version:"6.7.0",sidebar:{position:"left",display:"always",offset:12,b2t:!1,scrollpercent:!0,onmobile:!0},fancybox:!0,fastclick:!0,lazyload:!0,tabs:!0,motion:{enable:!0,async:!0,transition:{post_block:"fadeIn",post_header:"slideDownIn",post_body:"slideDownIn",coll_header:"slideLeftIn",sidebar:"slideUpIn"}},algolia:{applicationID:"",apiKey:"",indexName:"",hits:{per_page:10},labels:{input_placeholder:"Search for Posts",hits_empty:"We didn't find any results for the search: ${query}",hits_stats:"${hits} results found in ${time} ms"}}}</script><meta name="baidu-site-verification" content="B2fOjPkYa7"><meta name="google-site-verification" content="OhdtVOx5uwpZ_mMm0AZJXzw-dY1PPpAAkdavmmQhIL4"><meta name="360-site-verification" content="5b1c9d7574859ca6e460dd687667d5dc"><meta name="shenma-site-verification" content="933461d02e7b7c40e5293ee90085127c_1569650330"><meta name="description" content="博客app下载介绍使用fusion app对网页进行的封装。功能：浏览本博客，主页私人网盘2048等小游戏在线客服，QQ等pc与移动浏览器标识切换留言，打赏，博主日志等分享功能，分享到QQ，微信，浏览器打开等app内添加书签，自动记录历史记录，刷新等配合博客的PWA + quicklink功能可实现离线浏览"><meta name="keywords" content="lua,fusion app,app,网页封装"><meta property="og:type" content="article"><meta property="og:title" content="博採眾長app"><meta property="og:url" content="https://lruihao.cn/posts/fas-app.html"><meta property="og:site_name" content="菠菜眾長"><meta property="og:description" content="博客app下载介绍使用fusion app对网页进行的封装。功能：浏览本博客，主页私人网盘2048等小游戏在线客服，QQ等pc与移动浏览器标识切换留言，打赏，博主日志等分享功能，分享到QQ，微信，浏览器打开等app内添加书签，自动记录历史记录，刷新等配合博客的PWA + quicklink功能可实现离线浏览"><meta property="og:locale" content="zh-CN"><meta property="og:updated_time" content="2019-09-13T02:58:13.303Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="博採眾長app"><meta name="twitter:description" content="博客app下载介绍使用fusion app对网页进行的封装。功能：浏览本博客，主页私人网盘2048等小游戏在线客服，QQ等pc与移动浏览器标识切换留言，打赏，博主日志等分享功能，分享到QQ，微信，浏览器打开等app内添加书签，自动记录历史记录，刷新等配合博客的PWA + quicklink功能可实现离线浏览"><link rel="alternate" href="/atom.xml" title="菠菜眾長" type="application/atom+xml"><link rel="canonical" href="https://lruihao.cn/posts/fas-app.html"><script type="text/javascript" id="page.configurations">CONFIG.page={sidebar:""}</script><title>博採眾長app | 菠菜眾長</title><script type="text/javascript">var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?d25f1e053205bf07562f33365fef04d7";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><noscript><style type="text/css">.sidebar-inner,.use-motion .brand,.use-motion .collection-title,.use-motion .comments,.use-motion .menu-item,.use-motion .motion-element,.use-motion .pagination,.use-motion .post-block,.use-motion .post-body,.use-motion .post-header{opacity:initial}.use-motion .logo,.use-motion .site-subtitle,.use-motion .site-title{opacity:initial;top:initial}.logo-line-after i{right:initial}</style></noscript></head><body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN"><div class="container sidebar-position-left page-post-detail"><div class="headband"></div><header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="header-inner"><div class="site-brand-wrapper"><div class="site-meta"><div class="custom-logo-site-title"><a href="/" class="brand" rel="start"><span class="logo-line-before"><i></i></span> <span class="site-title">菠菜众长</span> <span class="logo-line-after"><i></i></span></a></div><h1 class="site-subtitle" itemprop="description">李瑞豪的博客</h1></div><div class="site-nav-toggle"><button aria-label="切换导航栏"><span class="btn-bar"></span> <span class="btn-bar"></span> <span class="btn-bar"></span></button></div></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i><br>首页</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i><br>归档<span class="badge">176</span></a></li><li class="menu-item menu-item-docs"><a href="/docs/" rel="section"><i class="menu-item-icon fa fa-fw fa-book"></i><br>综合</a></li><li class="menu-item menu-item-album"><a href="https://img.lruihao.cn" rel="external nofollow noopener noreferrer" target="_blank"><i class="menu-item-icon fa fa-fw fa-image"></i><br>相册</a></li><li class="menu-item menu-item-guestbook"><a href="/guestbook/" rel="section"><i class="menu-item-icon fa fa-fw fa-comments"></i><br>留言</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-address-card"></i><br>关于</a></li><li class="menu-item menu-item-search"><a href="javascript:;" class="popup-trigger"><i class="menu-item-icon fa fa-search fa-fw"></i><br>搜索</a></li></ul><div class="site-search"><div class="popup search-popup local-search-popup"><div class="local-search-header clearfix"><span class="search-icon"><i class="fa fa-search"></i> </span><span class="popup-btn-close"><i class="fa fa-times-circle"></i></span><div class="local-search-input-wrapper"><input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input"></div></div><div id="local-search-result"><div style="text-align:center;padding:3px 0 0"><div style="margin-top:20px;font-size:18px;font-weight:600;border-bottom:1px solid #ccc"><i class="fa fa-history" aria-hidden="true"></i> 近期文章</div><ul style="margin:0;padding:0;list-style:none"><li><a href="/posts/csdnvisiter.html" title="使用Python刷csdn访问量" target="_blank">使用Python刷csdn访问量</a></li><li><a href="/posts/cron.html" title="CRON表达式的基本语法" target="_blank">CRON表达式的基本语法</a></li><li><a href="/posts/daka.html" title="新冠疫情未返校未返工第N天之“自动打卡”" target="_blank">新冠疫情未返校未返工第N天之“自动打卡”</a></li><li><a href="/posts/year-2019.html" title="2019年度总结" target="_blank">2019年度总结</a></li><li><a href="/posts/sql.html" title="SQL总结" target="_blank">SQL总结</a></li><li><a href="/posts/cos-album.html" title="利用腾讯云为静态页面添加“动态”相册" target="_blank">利用腾讯云为静态页面添加“动态”相册</a></li><li><a href="/posts/restful.html" title="RESTful" target="_blank">RESTful</a></li><li><a href="/posts/phpPushUrl.html" title="php同时主动推送链接到百度，神马等站长平台" target="_blank">php同时主动推送链接到百度，神马等站长平台</a></li><li><a href="/posts/phpfile.html" title="php按行读取文件信息" target="_blank">php按行读取文件信息</a></li><li><a href="/posts/site-time.html" title="设置网站运行时间" target="_blank">设置网站运行时间</a></li><li><a href="/posts/async-defer.html" title="script的三种加载方式（async、defer）" target="_blank">script的三种加载方式（async、defer）</a></li><li><a href="/posts/Sublime-Text3.html" title="Sublime Text3快捷键大全" target="_blank">Sublime Text3快捷键大全</a></li><li><a href="/posts/netBeans.html" title="netBeans IDE开发设置" target="_blank">netBeans IDE开发设置</a></li><li><a href="/posts/dev-rules.html" title="web开发规则，代码规范" target="_blank">web开发规则，代码规范</a></li><li><a href="/posts/phpform.html" title="简单评论模块--php表单练习" target="_blank">简单评论模块--php表单练习</a></li></ul></div></div></div></div></nav></div></header><a href="https://github.com/Lruihao/lruihao.github.io" class="github-corner" target="_blank" title="万水千山总是情,给个star行不行！" aria-label="万水千山总是情,给个star行不行！" rel="external nofollow noopener noreferrer"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#222;color:#fff;position:absolute;top:0;border:0;right:0" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin:130px 106px" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><main id="main" class="main"><div class="main-inner"><div class="content-wrap"><div id="content" class="content"><div id="posts" class="posts-expand"><div class="reading-progress-bar"></div><article class="post post-type-normal" itemscope itemtype="http://schema.org/Article"><div class="post-block"><link itemprop="mainEntityOfPage" href="https://lruihao.cn/posts/fas-app.html"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="李瑞豪"><meta itemprop="description" content="从ACM到Web，分享程序、技巧、干货，记录心情、学习、成长！"><meta itemprop="image" content="/images/avatar.png"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="菠菜眾長"></span><header class="post-header"><h2 class="post-title" itemprop="name headline"><span class="post-delicate-flag" title="精品"><i class="fa fa-newspaper-o"></i> </span>博採眾長app<a href="https://github.com/Lruihao/lruihao.github.io/tree/hexo/source/_posts/fas-app.md" class="post-edit-link" title="编辑" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-pencil"></i></a></h2><div class="post-meta"><span class="post-time"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i> </span><span class="post-meta-item-text">发表于</span> <time title="创建时间：2018-11-12 16:04:04" itemprop="dateCreated datePublished" datetime="2018-11-12T16:04:04+08:00">2018-11-12</time> </span><span class="post-category"><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-folder-o"></i> </span><span class="post-meta-item-text">分类于</span> <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/others/" itemprop="url" rel="index"><span itemprop="name">others</span></a></span> </span><span class="post-comments-count"><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-comment-o"></i> </span><span class="post-meta-item-text">评论数： </span><a href="/posts/fas-app.html#comments" itemprop="discussionUrl"><span class="post-comments-count valine-comment-count" data-xid="/posts/fas-app.html" itemprop="commentCount"></span> </a></span><span id="/posts/fas-app.html" class="leancloud_visitors" data-flag-title="博採眾長app"><span class="post-meta-divider">|</span> <span title="阅读次数"><span class="post-meta-item-icon"><i class="fa fa-eye"></i> </span><span class="post-meta-item-text">阅读次数：</span> <span class="leancloud-visitors-count"></span></span></span><div class="post-symbolscount"><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-file-word-o"></i> </span><span class="post-meta-item-text">本文字数：</span> <span title="本文字数">2,914</span> <span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-clock-o"></i> </span><span class="post-meta-item-text">阅读时长 &asymp;</span> <span title="阅读时长">13 分钟</span></div></div></header><div class="post-body" itemprop="articleBody"><p><a href="https://ziyuan.lruihao.cn/app/bczc_2.6.2.apk" target="_blank" class="LinkCard">博客app下载</a></p><h3 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h3><p>使用fusion app对网页进行的封装。<br>功能：</p><ul><li>浏览本博客，主页</li><li>私人网盘</li><li>2048等小游戏</li><li>在线客服，QQ等</li><li>pc与移动浏览器标识切换</li><li>留言，打赏，博主日志等</li><li>分享功能，分享到QQ，微信，浏览器打开等</li><li>app内添加书签，自动记录历史记录，刷新等</li><li><strong>配合博客的<code>PWA + quicklink</code>功能可实现离线浏览</strong><a id="more"></a></li></ul><h3 id="下载"><a href="#下载" class="headerlink" title="下载"></a>下载</h3><blockquote><p><del>app内也可以更新，不过就我自己用，懒得更新。</del></p></blockquote><ul><li><a href="https://pan.baidu.com/s/19jOvnNhssF302Mi1GRa2Sw" rel="external nofollow noopener noreferrer" target="_blank">百度云，密码:479l</a></li><li><a href="https://github.com/Lruihao/Blog_fas_apk" rel="external nofollow noopener noreferrer" target="_blank">github下载</a></li></ul><p><strong>PWA应用</strong></p><ol><li>地址栏输入: Chrome://flags</li><li>搜索并启用以下项目: Desktop PWAs(桌面PWAs)、App Banners(应用横幅)、Experimental App Banners(实验性应用横幅)</li><li>重启浏览器使修改的设置生效</li><li>点击地址栏最右边按钮</li><li>安装“博採眾長”</li></ol><h3 id="部分源码"><a href="#部分源码" class="headerlink" title="部分源码"></a>部分源码</h3><div class="note"><p>看到这些中文的函数总觉得怪怪的哈哈哈😂<br>语言：<code>lua</code></p></div><h4 id="检测更新"><a href="#检测更新" class="headerlink" title="检测更新"></a>检测更新</h4><figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">--检查测当前是否最新版本</span></span><br><span class="line"><span class="keyword">local</span> dl=ProgressDialog.show(activity,<span class="literal">nil</span>,<span class="string">'更新检测中…'</span>)</span><br><span class="line">dl.show()</span><br><span class="line"><span class="keyword">local</span> tt=Ticker()</span><br><span class="line">tt.start()</span><br><span class="line">packinfo=this.getPackageManager().getPackageInfo(this.getPackageName(),((<span class="number">32552732</span>/<span class="number">2</span>/<span class="number">2</span><span class="number">-8183</span>)/<span class="number">10000</span><span class="number">-6</span><span class="number">-231</span>)/<span class="number">9</span>)</span><br><span class="line">version=<span class="built_in">tostring</span>(packinfo.versionName)</span><br><span class="line">versioncode=<span class="built_in">tostring</span>(packinfo.versionCode)</span><br><span class="line"></span><br><span class="line">url=<span class="string">"https://share.weiyun.com/43fa66d8fc95db27141530ed2d006be2"</span>;</span><br><span class="line"><span class="function"><span class="keyword">function</span> 过滤<span class="params">(content)</span></span></span><br><span class="line">  版本名=content:<span class="built_in">match</span>(<span class="string">"【版本名】(.-)【版本名】"</span>)</span><br><span class="line">  版本=content:<span class="built_in">match</span>(<span class="string">"【版本】(.-)【版本】"</span>)</span><br><span class="line">  内容=content:<span class="built_in">match</span>(<span class="string">"【内容】(.-)【内容】"</span>)</span><br><span class="line">  链接=content:<span class="built_in">match</span>(<span class="string">"【链接】(.-)【链接】"</span>)</span><br><span class="line"><span class="keyword">if</span>(版本名==<span class="literal">nil</span>) <span class="keyword">then</span></span><br><span class="line">  版本名=<span class="string">"获取失败"</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="keyword">if</span>(版本==<span class="literal">nil</span>) <span class="keyword">then</span></span><br><span class="line">  版本=<span class="string">"0"</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="keyword">if</span>(内容==<span class="literal">nil</span>) <span class="keyword">then</span></span><br><span class="line">  内容=<span class="string">"获取失败"</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="keyword">if</span>(链接==<span class="literal">nil</span>) <span class="keyword">then</span></span><br><span class="line">  弹出消息(<span class="string">"服务器参数配置错误，请过段时间再次尝试"</span>)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span>(版本 &gt; versioncode) <span class="keyword">then</span></span><br><span class="line">  dl.dismiss()</span><br><span class="line">    tt.stop() </span><br><span class="line">对话框()</span><br><span class="line">.设置标题(<span class="string">"检测到更新"</span>)</span><br><span class="line">.设置消息(<span class="string">"版本："</span>..version..<span class="string">"→"</span>..版本名..<span class="string">"\n更新内容："</span>..内容)</span><br><span class="line">.设置积极按钮(<span class="string">"下载更新"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">  下载文件(链接)</span><br><span class="line">  弹出消息(<span class="string">"下载更新中…"</span>)</span><br><span class="line"><span class="keyword">end</span>)</span><br><span class="line">.设置消极按钮(<span class="string">"取消更新"</span>)</span><br><span class="line">.显示()</span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">dl.dismiss()</span><br><span class="line">    tt.stop()</span><br><span class="line">弹出消息(<span class="string">"当前已是最新版本！"</span>)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line">Http.get(url,<span class="literal">nil</span>,<span class="string">"UTF-8"</span>,<span class="literal">nil</span>,<span class="function"><span class="keyword">function</span><span class="params">(code,content,cookie,header)</span></span></span><br><span class="line">  <span class="keyword">if</span>(code==<span class="number">200</span> <span class="keyword">and</span> content)<span class="keyword">then</span></span><br><span class="line">    content=content:<span class="built_in">match</span>(<span class="string">"\"html_content\":(.-),"</span>):<span class="built_in">gsub</span>(<span class="string">"\\u003C/?.-%&gt;"</span>,<span class="string">""</span>):<span class="built_in">gsub</span>(<span class="string">"\\\\"</span>,<span class="string">"&amp;revs;"</span>):<span class="built_in">gsub</span>(<span class="string">"\\n"</span>,<span class="string">"\n"</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;nbsp;"</span>,<span class="string">" "</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;lt;"</span>,<span class="string">"&lt;"</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;gt;"</span>,<span class="string">"&gt;"</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;quot;"</span>,<span class="string">"\""</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;apos;"</span>,<span class="string">"'"</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;revs;"</span>,<span class="string">"\\"</span>):<span class="built_in">gsub</span>(<span class="string">"&amp;amp;"</span>,<span class="string">"&amp;"</span>);</span><br><span class="line">    过滤(content)</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">  dl.dismiss()</span><br><span class="line">    tt.stop() </span><br><span class="line">     弹出消息(<span class="string">"本地网络或服务器异常 "</span>..code)</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span>)</span><br></pre></td></tr></table></figure><h4 id="方向锁定"><a href="#方向锁定" class="headerlink" title="方向锁定"></a>方向锁定</h4><figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">--flag在程序启动事件声明的全局变量</span></span><br><span class="line"><span class="keyword">if</span> flag==<span class="number">1</span> <span class="keyword">then</span></span><br><span class="line">  activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);</span><br><span class="line">  SetHSP=<span class="string">"H"</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">  SetHSP=<span class="literal">nil</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> SetHSP==<span class="literal">nil</span> <span class="keyword">then</span></span><br><span class="line">  <span class="comment">--竖屏锁定</span></span><br><span class="line">  activity.setRequestedOrientation(<span class="number">1</span>);</span><br><span class="line">  flag=<span class="number">1</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">  flag=<span class="number">0</span></span><br><span class="line"><span class="keyword">end</span></span><br></pre></td></tr></table></figure><h4 id="程序启动事件"><a href="#程序启动事件" class="headerlink" title="程序启动事件"></a>程序启动事件</h4><figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br></pre></td><td class="code"><pre><span class="line">弹出消息(<span class="string">"©2018 李瑞豪"</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">--自动，由物理感应器决定</span></span><br><span class="line">import <span class="string">"android.content.pm.ActivityInfo"</span></span><br><span class="line">flag=<span class="number">1</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--程序退出时执行对话框</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">onKeyDown</span><span class="params">(key,event)</span></span></span><br><span class="line">  <span class="keyword">if</span>(key==<span class="number">4</span>)<span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span>(webView.canGoBack())<span class="keyword">then</span></span><br><span class="line">      webView.goBack()</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      appinfo=this.getPackageManager().getApplicationInfo(this.getPackageName(),<span class="number">0</span>)</span><br><span class="line">      applabel=this.getPackageManager().getApplicationLabel(appinfo)</span><br><span class="line">      退出确认=对话框()</span><br><span class="line">      .设置消息(<span class="string">"您确定要退出 "</span>..applabel..<span class="string">" 吗?"</span>)</span><br><span class="line">      退出按钮=&#123;</span><br><span class="line">        [<span class="number">1</span>]=<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">          退出确认</span><br><span class="line">          .设置积极按钮(<span class="string">"确认"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">            退出程序()</span><br><span class="line">            <span class="keyword">end</span></span><br><span class="line">             )</span><br><span class="line">             .设置中立按钮(<span class="string">"清除缓存"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">               对话框()</span><br><span class="line">               .设置消息(<span class="string">"清除缓存后再次运行程序将变得缓慢\n您确定要清除 "</span>..applabel..<span class="string">" 的缓存吗?"</span>)</span><br><span class="line">               .设置积极按钮(<span class="string">"确定"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">                <span class="built_in">os</span>.<span class="built_in">execute</span>(<span class="string">"pm clear "</span>..this.packageName)</span><br><span class="line">                退出程序()</span><br><span class="line">                <span class="keyword">end</span>)</span><br><span class="line">               .设置消极按钮(<span class="string">"取消"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">                <span class="keyword">end</span>)</span><br><span class="line">              .显示()</span><br><span class="line">             <span class="keyword">end</span></span><br><span class="line">           )</span><br><span class="line">          .设置消极按钮(<span class="string">"取消"</span>)</span><br><span class="line">          <span class="keyword">end</span></span><br><span class="line">        &#125;      </span><br><span class="line">      <span class="built_in">math</span>.<span class="built_in">randomseed</span>(<span class="built_in">tonumber</span>(<span class="built_in">tostring</span>(<span class="built_in">os</span>.<span class="built_in">time</span>()):<span class="built_in">reverse</span>():<span class="built_in">sub</span>(<span class="number">1</span>, <span class="number">6</span>)))</span><br><span class="line">      退出按钮[<span class="built_in">math</span>.<span class="built_in">random</span>(<span class="number">1</span>,<span class="number">1</span>)]()</span><br><span class="line">      退出确认.show()</span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--历史记录</span></span><br><span class="line">lstads=<span class="string">"/data/data/"</span>..activity.getPackageName()..<span class="string">"/lst.lua"</span></span><br><span class="line">lstwebads=<span class="string">"/data/data/"</span>..activity.getPackageName()..<span class="string">"/lstweb.lua"</span></span><br><span class="line"><span class="comment">--2.序列化</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">slz</span><span class="params">(obj)</span></span> </span><br><span class="line">  <span class="keyword">local</span> lua = <span class="string">""</span> </span><br><span class="line">  <span class="keyword">local</span> t = <span class="built_in">type</span>(obj) </span><br><span class="line">  <span class="keyword">if</span> t == <span class="string">"number"</span> <span class="keyword">then</span> </span><br><span class="line">    lua = lua .. obj </span><br><span class="line">  <span class="keyword">elseif</span> t == <span class="string">"boolean"</span> <span class="keyword">then</span> </span><br><span class="line">    lua = lua .. <span class="built_in">tostring</span>(obj) </span><br><span class="line">  <span class="keyword">elseif</span> t == <span class="string">"string"</span> <span class="keyword">then</span> </span><br><span class="line">    lua = lua .. <span class="built_in">string</span>.<span class="built_in">format</span>(<span class="string">"%q"</span>, obj) </span><br><span class="line">  <span class="keyword">elseif</span> t == <span class="string">"table"</span> <span class="keyword">then</span> </span><br><span class="line">    lua = lua .. <span class="string">"&#123;\n"</span> </span><br><span class="line">    <span class="keyword">for</span> k, v <span class="keyword">in</span> <span class="built_in">pairs</span>(obj) <span class="keyword">do</span> </span><br><span class="line">      lua = lua .. <span class="string">"["</span> .. slz(k) .. <span class="string">"]="</span> .. slz(v) .. <span class="string">",\n"</span> </span><br><span class="line">    <span class="keyword">end</span> </span><br><span class="line">    <span class="keyword">local</span> metatable = <span class="built_in">getmetatable</span>(obj) </span><br><span class="line">    <span class="keyword">if</span> metatable ~= <span class="literal">nil</span> <span class="keyword">and</span> <span class="built_in">type</span>(metatable.<span class="built_in">__index</span>) == <span class="string">"table"</span> <span class="keyword">then</span> </span><br><span class="line">      <span class="keyword">for</span> k, v <span class="keyword">in</span> <span class="built_in">pairs</span>(metatable.<span class="built_in">__index</span>) <span class="keyword">do</span> </span><br><span class="line">        lua = lua .. <span class="string">"["</span> .. slz(k) .. <span class="string">"]="</span> .. slz(v) .. <span class="string">",\n"</span> </span><br><span class="line">      <span class="keyword">end</span> </span><br><span class="line">    <span class="keyword">end</span> </span><br><span class="line">    lua = lua .. <span class="string">"&#125;"</span> </span><br><span class="line">  <span class="keyword">elseif</span> t == <span class="string">"nil"</span> <span class="keyword">then</span> </span><br><span class="line">    <span class="keyword">return</span> <span class="literal">nil</span> </span><br><span class="line">  <span class="keyword">else</span> </span><br><span class="line">    <span class="built_in">error</span>(<span class="string">"can not serialize a "</span> .. t .. <span class="string">" type."</span>) </span><br><span class="line">  <span class="keyword">end</span> </span><br><span class="line">  <span class="keyword">return</span> lua </span><br><span class="line"><span class="keyword">end</span> </span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">rslz</span><span class="params">(lua)</span></span> </span><br><span class="line">  <span class="keyword">local</span> t = <span class="built_in">type</span>(lua) </span><br><span class="line">  <span class="keyword">if</span> t == <span class="string">"nil"</span> <span class="keyword">or</span> lua == <span class="string">""</span> <span class="keyword">then</span> </span><br><span class="line">    <span class="keyword">return</span> &#123;&#125;</span><br><span class="line">  <span class="keyword">elseif</span> t == <span class="string">"number"</span> <span class="keyword">or</span> t == <span class="string">"string"</span> <span class="keyword">or</span> t == <span class="string">"boolean"</span> <span class="keyword">then</span> </span><br><span class="line">    lua = <span class="built_in">tostring</span>(lua) </span><br><span class="line">  <span class="keyword">else</span> </span><br><span class="line">    <span class="built_in">error</span>(<span class="string">"can not unserialize a "</span> .. t .. <span class="string">" type."</span>) </span><br><span class="line">  <span class="keyword">end</span> </span><br><span class="line">  lua = <span class="string">"return "</span> .. lua </span><br><span class="line">  <span class="keyword">local</span> func = loadstring(lua) </span><br><span class="line">  <span class="keyword">if</span> func == <span class="literal">nil</span> <span class="keyword">then</span> </span><br><span class="line">    <span class="keyword">return</span> <span class="literal">nil</span> </span><br><span class="line">  <span class="keyword">end</span> </span><br><span class="line">  <span class="keyword">return</span> func() </span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--3.历史记录框布局</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">hstshow</span><span class="params">()</span></span></span><br><span class="line">  hstlayout=&#123;</span><br><span class="line">    LinearLayout,</span><br><span class="line">    orientation=<span class="string">"1"</span>,</span><br><span class="line">    gravity=<span class="string">"center"</span>,</span><br><span class="line">    layout_width=<span class="string">"wrap_content"</span>,</span><br><span class="line">    layout_height=<span class="string">"wrap_content"</span>,</span><br><span class="line">    &#123;</span><br><span class="line">      TextView,</span><br><span class="line">      text=<span class="string">""</span>,</span><br><span class="line">      gravity=<span class="string">"center"</span>,</span><br><span class="line">      layout_width=<span class="string">"wrap_content"</span>,</span><br><span class="line">      textSize=<span class="string">"0sp"</span>,</span><br><span class="line">      background=<span class="string">"#000000"</span>,</span><br><span class="line">      layout_height=<span class="string">"15dp"</span>,&#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      TextView,</span><br><span class="line">      text=<span class="string">"历史记录"</span>,</span><br><span class="line">      gravity=<span class="string">"center"</span>,</span><br><span class="line">      layout_width=<span class="string">"wrap_content"</span>,</span><br><span class="line">      textSize=<span class="string">"30sp"</span>,</span><br><span class="line">      textStyle=<span class="string">"bold"</span>,</span><br><span class="line">      layout_height=<span class="string">"50dp"</span>,&#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      ListView,</span><br><span class="line">      id=<span class="string">"hlst"</span>,</span><br><span class="line">      items=lst,</span><br><span class="line">      layout_width=<span class="string">"fill"</span>,</span><br><span class="line">      layout_height=<span class="string">"wrap_content"</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--##功能函数##</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--1.读取历史文件</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">read_hst</span><span class="params">()</span></span></span><br><span class="line">  import <span class="string">"java.io.File"</span></span><br><span class="line">  File(lstads).createNewFile()</span><br><span class="line">  slst=<span class="built_in">io</span>.<span class="built_in">open</span>(lstads):<span class="built_in">read</span>(<span class="string">"*a"</span>)</span><br><span class="line">  File(lstwebads).createNewFile()</span><br><span class="line">  slstweb=<span class="built_in">io</span>.<span class="built_in">open</span>(lstwebads):<span class="built_in">read</span>(<span class="string">"*a"</span>)</span><br><span class="line">  <span class="comment">--转换成table</span></span><br><span class="line">  lst=rslz(slst)</span><br><span class="line">  lstweb=rslz(slstweb)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--2.新网页加入历史记录</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">add_hst</span><span class="params">()</span></span></span><br><span class="line">  <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">len</span>(webView.getTitle())&lt;=<span class="number">300</span> <span class="keyword">then</span><span class="comment">--粗略过掉无效标题</span></span><br><span class="line">    newtitle=webView.getTitle()</span><br><span class="line">    newurl=webView.getUrl()</span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">insert</span>(lst,<span class="number">1</span>,newtitle) <span class="comment">--标题表添加新标题</span></span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">insert</span>(lstweb,<span class="number">1</span>,newurl) <span class="comment">--网址表添加新网址</span></span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--3.存储历史文件</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">save_hst</span><span class="params">()</span></span></span><br><span class="line">  <span class="comment">--转换成string</span></span><br><span class="line">  slst=slz(lst)</span><br><span class="line">  slstweb=slz(lstweb)</span><br><span class="line">  <span class="comment">--保存</span></span><br><span class="line">  file=<span class="built_in">io</span>.<span class="built_in">open</span>(lstads,<span class="string">"w+"</span>)</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">output</span>(file)</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">write</span>(slst)</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">flush</span>()</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">close</span>(file)</span><br><span class="line">  file=<span class="built_in">io</span>.<span class="built_in">open</span>(lstwebads,<span class="string">"w+"</span>)</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">output</span>(file)</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">write</span>(slstweb)</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">flush</span>()</span><br><span class="line">  <span class="built_in">io</span>.<span class="built_in">close</span>(file)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--4.显示历史记录框</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">show_hst</span><span class="params">()</span></span> </span><br><span class="line">  hstshow()</span><br><span class="line">  <span class="keyword">local</span> hl=AlertDialog.Builder(activity)</span><br><span class="line">  .setView(loadlayout(hstlayout))</span><br><span class="line">  .setNegativeButton(<span class="string">"取消"</span>,DialogInterface.OnClickListener&#123;</span><br><span class="line">    onClick=<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">  &#125;)</span><br><span class="line">  .<span class="built_in">create</span>()</span><br><span class="line">  hl.show()</span><br><span class="line">  hlst.onItemClick=<span class="function"><span class="keyword">function</span><span class="params">(l,v,c,b)</span></span></span><br><span class="line">    加载网页(lstweb[b])</span><br><span class="line">    hl.dismiss()</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  hlst.onItemLongClick=<span class="function"><span class="keyword">function</span><span class="params">(l,v,c,b)</span></span></span><br><span class="line">    hl.dismiss()</span><br><span class="line">    对话框()</span><br><span class="line">    .设置消息(<span class="string">"是否删除记录？"</span>)</span><br><span class="line">    .设置消极按钮(<span class="string">"取消"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">      show_hst()</span><br><span class="line">    <span class="keyword">end</span>)</span><br><span class="line">    .设置积极按钮(<span class="string">"确定"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">      <span class="built_in">table</span>.<span class="built_in">remove</span>(lst,b)</span><br><span class="line">      <span class="built_in">table</span>.<span class="built_in">remove</span>(lstweb,b)</span><br><span class="line">      save_hst()</span><br><span class="line">      show_hst()</span><br><span class="line">    <span class="keyword">end</span> )</span><br><span class="line">    .显示()</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="comment">--5.清除缓存</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">clr</span><span class="params">()</span></span></span><br><span class="line">  <span class="comment">--导入File类</span></span><br><span class="line">  import <span class="string">"java.io.File"</span></span><br><span class="line">  <span class="comment">--显示多选框</span></span><br><span class="line">  items=&#123;<span class="string">"浏览记录"</span>,<span class="string">"缓存文件"</span>&#125;</span><br><span class="line">  多选对话框=AlertDialog.Builder(this)</span><br><span class="line">  .setTitle(<span class="string">"清除记录"</span>)</span><br><span class="line">  <span class="comment">--勾选后执行</span></span><br><span class="line">  .setPositiveButton(<span class="string">"确定"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">    <span class="keyword">if</span> clearhistory==<span class="number">1</span> <span class="keyword">and</span> clearall==<span class="number">1</span> <span class="keyword">then</span></span><br><span class="line">      File(lstads).delete()</span><br><span class="line">      File(lstwebads).delete()</span><br><span class="line">      lst=&#123;&#125;</span><br><span class="line">      lstweb=&#123;&#125;</span><br><span class="line">      <span class="built_in">os</span>.<span class="built_in">execute</span>(<span class="string">"pm clear "</span>..activity.getPackageName())</span><br><span class="line">    <span class="keyword">elseif</span> clearhistory==<span class="number">0</span> <span class="keyword">and</span> clearall==<span class="number">1</span> <span class="keyword">then</span></span><br><span class="line">      <span class="built_in">os</span>.<span class="built_in">execute</span>(<span class="string">"pm clear "</span>..activity.getPackageName())</span><br><span class="line">    <span class="keyword">elseif</span> clearhistory==<span class="number">1</span> <span class="keyword">and</span> clearall==<span class="number">0</span> <span class="keyword">then</span></span><br><span class="line">      File(lstads).delete()</span><br><span class="line">      File(lstwebads).delete()</span><br><span class="line">      lst=&#123;&#125;</span><br><span class="line">      lstweb=&#123;&#125;</span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">nil</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">end</span>)</span><br><span class="line">  <span class="comment">--选择事件</span></span><br><span class="line">  .setMultiChoiceItems(items, <span class="literal">nil</span>,&#123; onClick=<span class="function"><span class="keyword">function</span><span class="params">(v,p)</span></span></span><br><span class="line">      <span class="comment">--清除历史</span></span><br><span class="line">      <span class="keyword">if</span> p==<span class="number">0</span> <span class="keyword">then</span> clearhistory=<span class="number">1</span></span><br><span class="line">      <span class="keyword">end</span></span><br><span class="line">      <span class="comment">--清除缓存</span></span><br><span class="line">      <span class="keyword">if</span> p==<span class="number">1</span> <span class="keyword">then</span> clearall=<span class="number">1</span></span><br><span class="line">      <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">end</span>&#125;)</span><br><span class="line">  多选对话框.show();</span><br><span class="line">  clearhistory=<span class="number">0</span></span><br><span class="line">  clearall=<span class="number">0</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);</span><br><span class="line"><span class="comment">--11.长按弹窗</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">popwin</span><span class="params">(od)</span></span></span><br><span class="line">  <span class="keyword">local</span> win1=<span class="string">"向上移动"</span></span><br><span class="line">  <span class="keyword">local</span> win2=<span class="string">"编辑"</span></span><br><span class="line">  <span class="keyword">local</span> win3=<span class="string">"向下移动"</span></span><br><span class="line">  <span class="keyword">local</span> wina=&#123;win1,win2,win3&#125;</span><br><span class="line">  <span class="keyword">local</span> winb=&#123;win2,win3&#125;</span><br><span class="line">  <span class="keyword">local</span> winc=&#123;win1,win2&#125;</span><br><span class="line">  <span class="keyword">if</span> od==<span class="number">1</span> <span class="keyword">then</span></span><br><span class="line">    win=winb</span><br><span class="line">  <span class="keyword">elseif</span> od==#fav <span class="keyword">then</span></span><br><span class="line">    win=winc</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    win=wina</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  winlayout=&#123;</span><br><span class="line">    LinearLayout,</span><br><span class="line">    orientation=<span class="string">"vertical"</span>,</span><br><span class="line">    &#123;ListView,</span><br><span class="line">      id=<span class="string">"winlv"</span>,</span><br><span class="line">      items=win,</span><br><span class="line">      layout_width=<span class="string">"fill_parent"</span>,</span><br><span class="line">      layout_height=<span class="string">"wrap_content"</span>,&#125;,</span><br><span class="line">  &#125;</span><br><span class="line">  winl=AlertDialog.Builder(activity)</span><br><span class="line">  .setView(loadlayout(winlayout))</span><br><span class="line">  .<span class="built_in">create</span>()</span><br><span class="line">  winl.show()</span><br><span class="line">  winlv.onItemClick=<span class="function"><span class="keyword">function</span><span class="params">(l,v,c,b)</span></span></span><br><span class="line">    <span class="keyword">if</span> win[b]==win1 <span class="keyword">then</span></span><br><span class="line">      fl.dismiss()</span><br><span class="line">      upfav(od)</span><br><span class="line">    <span class="keyword">elseif</span> win[b]==win2 <span class="keyword">then</span></span><br><span class="line">      fl.dismiss()</span><br><span class="line">      show_efav(od)</span><br><span class="line">    <span class="keyword">elseif</span> win[b]==win3 <span class="keyword">then</span></span><br><span class="line">      fl.dismiss()</span><br><span class="line">      downfav(od)</span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    winl.dismiss()</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">downfav</span><span class="params">(b)</span></span></span><br><span class="line">  <span class="keyword">if</span> b~=#fav <span class="keyword">then</span></span><br><span class="line">    dfav=fav[b]</span><br><span class="line">    dfavweb=favweb[b]</span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">remove</span>(fav,b)</span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">remove</span>(favweb,b)</span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">insert</span>(fav,b+<span class="number">1</span>,dfav)</span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">insert</span>(favweb,b+<span class="number">1</span>,dfavweb)</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  save_fav()</span><br><span class="line">  show_fav()</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--加入收藏</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getAllData</span><span class="params">(name)</span></span></span><br><span class="line">  <span class="keyword">local</span> data=&#123;&#125;</span><br><span class="line">  <span class="keyword">for</span> d <span class="keyword">in</span> each(this.getApplicationContext().getSharedPreferences(name,<span class="number">0</span>).getAll().entrySet()) <span class="keyword">do</span></span><br><span class="line">    data[d.getKey()]=d.getValue()</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">return</span> data</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getData</span><span class="params">(name,key,MzI1NTI3MzI)</span></span></span><br><span class="line">  <span class="keyword">local</span> data=this.getApplicationContext().getSharedPreferences(name,<span class="number">0</span>).getString(key,<span class="literal">nil</span>)<span class="comment">--325-5273-2</span></span><br><span class="line">  <span class="keyword">return</span> data</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">putData</span><span class="params">(name,key,value)</span></span></span><br><span class="line">  this.getApplicationContext().getSharedPreferences(name,<span class="number">0</span>).edit().putString(key,value).apply()<span class="comment">--3255-2732</span></span><br><span class="line">  <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">removeData</span><span class="params">(name,key)</span></span></span><br><span class="line">  this.getApplicationContext().getSharedPreferences(name,<span class="number">32552732</span>*<span class="number">0</span>).edit().<span class="built_in">remove</span>(key).apply()<span class="comment">--[[3(2)6?5&#123;2&#125;2[7]32]]</span></span><br><span class="line">  <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">listKeys</span><span class="params">(data)</span></span></span><br><span class="line">  keys=&#123;&#125;</span><br><span class="line">  emmm=<span class="number">24411107</span>+<span class="number">8236000</span>+<span class="number">236</span><span class="number">-95463</span>+<span class="number">852</span></span><br><span class="line">  <span class="keyword">for</span> k,v <span class="keyword">in</span> <span class="built_in">pairs</span>(data) <span class="keyword">do</span></span><br><span class="line">    keys[#keys+<span class="number">1</span>]=k</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">return</span> keys</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">listValues</span><span class="params">(data,MzI1NTI3MzI)</span></span></span><br><span class="line">  values=&#123;&#125;</span><br><span class="line">  <span class="keyword">for</span> k,v <span class="keyword">in</span> <span class="built_in">pairs</span>(data) <span class="keyword">do</span></span><br><span class="line">    values[#values+<span class="number">1</span>]=v</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  q=<span class="string">"325 52732"</span></span><br><span class="line">  <span class="keyword">return</span> values</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">adapterData</span><span class="params">(data,jdpuk)</span></span></span><br><span class="line">  adpd=&#123;&#125;</span><br><span class="line">  <span class="keyword">for</span> d <span class="keyword">in</span> <span class="built_in">pairs</span>(data) <span class="keyword">do</span></span><br><span class="line">    <span class="built_in">table</span>.<span class="built_in">insert</span>(adpd,&#123;</span><br><span class="line">      text=&#123;</span><br><span class="line">        Text=<span class="built_in">tostring</span>(data[d]), </span><br><span class="line">      &#125;, </span><br><span class="line">    &#125;)</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">return</span> adpd</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> listlayout=&#123;</span><br><span class="line">  LinearLayout,</span><br><span class="line">  orientation=<span class="string">"1"</span>,</span><br><span class="line">  layout_width=<span class="string">"fill"</span>,</span><br><span class="line">  layout_height=<span class="string">"wrap_content"</span>,</span><br><span class="line">  &#123;</span><br><span class="line">    ListView,</span><br><span class="line">    id=<span class="string">"list"</span>,</span><br><span class="line">    layout_marginTop=<span class="string">"10dp"</span>,</span><br><span class="line">    <span class="comment">--items=&#123;"3","2","5","5","2","7","3","2"&#125;,</span></span><br><span class="line">    layout_width=<span class="string">"fill"</span>,</span><br><span class="line">    layout_height=<span class="string">"wrap_content"</span>,</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> inputlayout=&#123;</span><br><span class="line">  LinearLayout,</span><br><span class="line">  orientation=<span class="string">"vertical"</span>,</span><br><span class="line">  Focusable=<span class="literal">true</span>,</span><br><span class="line">  FocusableInTouchMode=<span class="literal">true</span>,</span><br><span class="line">  &#123;</span><br><span class="line">    EditText,</span><br><span class="line">    id=<span class="string">"edit"</span>,</span><br><span class="line">    hint=<span class="string">"Input here"</span>,</span><br><span class="line">    layout_marginTop=<span class="string">"5dp"</span>,</span><br><span class="line">    layout_width=<span class="string">"80%w"</span>,</span><br><span class="line">    <span class="comment">--uh="32552732",</span></span><br><span class="line">    layout_gravity=<span class="string">"center"</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> input2layout=&#123;</span><br><span class="line">  LinearLayout,</span><br><span class="line">  orientation=<span class="string">"vertical"</span>,</span><br><span class="line">  Focusable=<span class="literal">true</span>,</span><br><span class="line">  FocusableInTouchMode=<span class="literal">true</span>,</span><br><span class="line">  &#123;</span><br><span class="line">    EditText,</span><br><span class="line">    id=<span class="string">"edit1"</span>,</span><br><span class="line">    hint=<span class="string">"Input here"</span>,</span><br><span class="line">    <span class="comment">--numa="32552",</span></span><br><span class="line">    <span class="comment">--aaa="bbb"</span></span><br><span class="line">    layout_marginTop=<span class="string">"5dp"</span>,</span><br><span class="line">    layout_width=<span class="string">"80%w"</span>,</span><br><span class="line">    layout_gravity=<span class="string">"center"</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">  &#123;</span><br><span class="line">    EditText,</span><br><span class="line">    id=<span class="string">"edit2"</span>,</span><br><span class="line">    <span class="comment">--ccc="ddd",</span></span><br><span class="line">    <span class="comment">--numb="732",</span></span><br><span class="line">    <span class="comment">--eee="fff",</span></span><br><span class="line">    hint=<span class="string">"Input here"</span>,</span><br><span class="line">    layout_margiTop=<span class="string">"5dp"</span>,</span><br><span class="line">    layout_width=<span class="string">"80%w"</span>,</span><br><span class="line">    layout_gravity=<span class="string">"center"</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">showDataDialog</span><span class="params">(name,title,jdpuk)</span></span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">local</span> data=getAllData(name)</span><br><span class="line">  <span class="keyword">local</span> keys=listKeys(data)</span><br><span class="line">  <span class="keyword">local</span> values=listValues(data)</span><br><span class="line"></span><br><span class="line">  item=&#123;</span><br><span class="line">    LinearLayout,</span><br><span class="line">    orientation=<span class="string">"vertical"</span>,</span><br><span class="line">    layout_width=<span class="string">"fill"</span>,</span><br><span class="line">    &#123;</span><br><span class="line">      TextView,</span><br><span class="line">      id=<span class="string">"text"</span>,</span><br><span class="line">      textSize=<span class="string">"16sp"</span>,</span><br><span class="line">      layout_margin=<span class="string">"10dp"</span>,</span><br><span class="line">      layout_width=<span class="string">"fill"</span>,</span><br><span class="line">      layout_width=<span class="string">"70%w"</span>,</span><br><span class="line">      layout_gravity=<span class="string">"center"</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">local</span> adpd=adapterData(values)</span><br><span class="line">  <span class="keyword">local</span> items=LuaAdapter(this,adpd,item)</span><br><span class="line"></span><br><span class="line">  <span class="keyword">local</span> dlb=对话框()</span><br><span class="line">  dlb.设置标题(title)</span><br><span class="line">  <span class="keyword">local</span> dl</span><br><span class="line">  <span class="keyword">if</span> #keys&gt;<span class="number">0</span> <span class="keyword">then</span></span><br><span class="line">    dlb.setView(loadlayout(listlayout))</span><br><span class="line">    list.setDividerHeight(<span class="number">0</span>)</span><br><span class="line">    list.Adapter=items</span><br><span class="line">    list.onItemClick=<span class="function"><span class="keyword">function</span><span class="params">(adp,view,position,id)</span></span><span class="comment">--3255273 2</span></span><br><span class="line">      webView.loadUrl(keys[id])</span><br><span class="line">      <span class="keyword">if</span> dl <span class="keyword">then</span></span><br><span class="line">        dl.dismiss()</span><br><span class="line">      <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    list.onItemLongClick=<span class="function"><span class="keyword">function</span><span class="params">(adp,view,pos,id)</span></span><span class="comment">--325 52732</span></span><br><span class="line">      对话框()</span><br><span class="line">      .设置标题(title)</span><br><span class="line">      .setView(loadlayout(input2layout))</span><br><span class="line">      .设置积极按钮(<span class="string">"保存"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span><span class="comment">--32552732</span></span><br><span class="line">        <span class="keyword">if</span> <span class="keyword">not</span>(edit1.text==<span class="string">""</span>) <span class="keyword">and</span> <span class="keyword">not</span>(edit2.text==<span class="string">""</span>) <span class="keyword">or</span> <span class="number">3255</span>==<span class="number">2732</span> <span class="keyword">then</span></span><br><span class="line">          removeData(name,keys[id])</span><br><span class="line">          putData(name,edit2.text,edit1.text)<span class="comment">--32552732</span></span><br><span class="line">          <span class="keyword">if</span> dl <span class="keyword">then</span></span><br><span class="line">            dl.dismiss()</span><br><span class="line">            showDataDialog(name,title)</span><br><span class="line">          <span class="keyword">end</span></span><br><span class="line">        <span class="keyword">else</span></span><br><span class="line">          弹出消息(<span class="string">"请填写所有字段"</span>)</span><br><span class="line">        <span class="keyword">end</span></span><br><span class="line">      <span class="keyword">end</span>)</span><br><span class="line">      .设置消极按钮(<span class="string">"取消"</span>)</span><br><span class="line">      .设置中立按钮(<span class="string">"删除"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">        removeData(name,keys[id])</span><br><span class="line">        items.<span class="built_in">remove</span>(pos)</span><br><span class="line">        <span class="built_in">table</span>.<span class="built_in">remove</span>(keys,id)</span><br><span class="line">        <span class="built_in">table</span>.<span class="built_in">remove</span>(values,id)</span><br><span class="line">        <span class="keyword">if</span> #adpd&lt;=<span class="number">0</span> <span class="keyword">then</span></span><br><span class="line">          <span class="keyword">if</span> dl <span class="keyword">then</span></span><br><span class="line">            dl.dismiss()</span><br><span class="line">            showDataDialog(name,title);</span><br><span class="line">          <span class="keyword">end</span></span><br><span class="line">        <span class="keyword">end</span></span><br><span class="line">      <span class="keyword">end</span>)</span><br><span class="line">      .显示()</span><br><span class="line">      edit1.setHint(<span class="string">"标题"</span>)</span><br><span class="line">      edit2.setHint(<span class="string">"链接"</span>)</span><br><span class="line">      edit1.setText(values[id])</span><br><span class="line">      edit2.setText(keys[id])</span><br><span class="line">      <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    dlb.设置消息(<span class="string">"没有收藏"</span>)</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  dlb.设置积极按钮(<span class="string">"新建收藏"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span>addDataDialog(name,<span class="string">"新建收藏"</span>)<span class="keyword">end</span>)</span><br><span class="line">  dl=dlb.show()</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">addDataDialog</span><span class="params">(name,title,value,key)</span></span><span class="comment">--32552732</span></span><br><span class="line">  对话框()</span><br><span class="line">  .设置标题(title)</span><br><span class="line">  .setView(loadlayout(input2layout))</span><br><span class="line">  .设置积极按钮(<span class="string">"保存"</span>,<span class="function"><span class="keyword">function</span><span class="params">()</span></span></span><br><span class="line">    <span class="keyword">if</span> <span class="keyword">not</span>(edit1.text==<span class="string">""</span>) <span class="keyword">and</span> <span class="keyword">not</span>(edit2.text==<span class="string">""</span>) <span class="keyword">or</span> <span class="number">325</span>==<span class="number">52732</span> <span class="keyword">then</span></span><br><span class="line">      <span class="keyword">if</span> <span class="keyword">not</span> getData(name,edit2.text) <span class="keyword">then</span></span><br><span class="line">        putData(name,edit2.text,edit1.text)</span><br><span class="line">      <span class="keyword">else</span></span><br><span class="line">        弹出消息(<span class="string">"该链接已存在"</span>)</span><br><span class="line">        addDataDialog(name,title,edit1.text,edit2.text)</span><br><span class="line">      <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      弹出消息(<span class="string">"请填写所有字段"</span>)</span><br><span class="line">      addDataDialog(name,title,edit1.text,edit2.text)</span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">end</span>)</span><br><span class="line">  .设置消极按钮(<span class="string">"取消"</span>)</span><br><span class="line">  .显示()</span><br><span class="line">  edit1.setHint(<span class="string">"标题"</span>)</span><br><span class="line">  edit2.setHint(<span class="string">"链接"</span>)</span><br><span class="line">  <span class="keyword">if</span>(value)<span class="keyword">then</span></span><br><span class="line">    edit1.setText(value)</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line">  <span class="keyword">if</span>(key)<span class="keyword">then</span></span><br><span class="line">    edit2.setText(key)</span><br><span class="line">  <span class="keyword">end</span></span><br><span class="line"><span class="keyword">end</span></span><br></pre></td></tr></table></figure></div><div class="popular-posts-header"><i class="fa fa-link"></i> 相关文章</div><!--[if !IE]><!--><details><summary style="cursor:pointer">点击查看</summary><!--<![endif]--><ul class="popular-posts"><li class="popular-posts-item"><div class="popular-posts-title"><a href="\posts\wex5.html" rel="bookmark">WeX5在win8或者win10操作系统studio中新建.w向导或其他的编辑窗口显示不全问题</a></div></li></ul><!--[if IE]><!--></details><!--<![endif]--><div><div style="padding:10px 0;margin:20px auto;width:90%;text-align:center"><div>欢迎关注公众号，感谢支持 ！</div><button id="rewardButton" disable="enable" onclick="var qr = document.getElementById(&quot;QR&quot;); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}"><span>赞赏</span></button><div id="QR" style="display:none"><div id="wechat" style="display:inline-block"><img id="wechat_qr" src="/images/wechatpay.gif" alt="李瑞豪 微信支付"><p>微信支付</p></div><div id="alipay" style="display:inline-block"><img id="alipay_qr" src="/images/alipay.gif" alt="李瑞豪 支付宝"><p>支付宝</p></div></div></div></div><div class="copyright-box"><ul class="post-copyright"><li class="post-copyright-author"><strong>本文作者： </strong>李瑞豪</li><li><strong>修改时间： </strong>2019-09-13 10:58:13</li><li class="post-copyright-link"><strong>本文链接：</strong> <a href="https://lruihao.cn/posts/fas-app.html" title="博採眾長app">https://lruihao.cn/posts/fas-app.html</a></li><li class="post-copyright-license"><strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-creative-commons"></i> BY-NC-SA 4.0</a> 许可协议。转载请注明出处！</li></ul></div><div class="post-tags"><a href="/tags/lua/" rel="tag"><i class="fa fa-tag"></i> lua</a> <a href="/tags/fusion-app/" rel="tag"><i class="fa fa-tag"></i> fusion app</a> <a href="/tags/app/" rel="tag"><i class="fa fa-tag"></i> app</a> <a href="/tags/网页封装/" rel="tag"><i class="fa fa-tag"></i> 网页封装</a></div><footer class="post-footer"><div class="post-nav"><div class="post-nav-next post-nav-item"><a href="/posts/caddy-file.html" rel="next" title="caddy-两步搭建超简单云盘"><i class="fa fa-chevron-left"></i> caddy-两步搭建超简单云盘</a></div><span class="post-nav-divider"></span><div class="post-nav-prev post-nav-item"><a href="/posts/commit-bat.html" rel="prev" title="通过bat批处理文件自动提交博客代码">通过bat批处理文件自动提交博客代码 <i class="fa fa-chevron-right"></i></a></div></div></footer></div></article></div></div><div class="comments" id="comments"></div></div><div class="sidebar-toggle"><div class="sidebar-toggle-line-wrap"><span class="sidebar-toggle-line sidebar-toggle-line-first"></span> <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span> <span class="sidebar-toggle-line sidebar-toggle-line-last"></span></div></div><aside id="sidebar" class="sidebar"><div id="sidebar-dimmer"></div><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">文章目录</li><li class="sidebar-nav-overview" data-target="site-overview-wrap">站点概览</li></ul><div class="site-overview-wrap sidebar-panel"><div class="site-overview"><div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person"><img class="site-author-image" itemprop="image" src="/images/avatar.png" alt="李瑞豪"><p class="site-author-name" itemprop="name">李瑞豪</p><p class="site-description motion-element" itemprop="description">从ACM到Web，分享程序、技巧、干货，记录心情、学习、成长！</p></div><nav class="site-state motion-element"><div class="site-state-item site-state-posts"><a href="/archives/"><span class="site-state-item-count">176</span> <span class="site-state-item-name">日志</span></a></div><div class="site-state-item site-state-categories"><a href="/docs/categories/index.html"><span class="site-state-item-count">25</span> <span class="site-state-item-name">分类</span></a></div><div class="site-state-item site-state-tags"><a href="/docs/tags/index.html"><span class="site-state-item-count">122</span> <span class="site-state-item-name">标签</span></a></div></nav><div class="feed-link motion-element"><a href="/atom.xml" rel="alternate"><i class="fa fa-rss"></i> RSS</a></div><div class="links-of-author motion-element"><span class="links-of-author-item"><a href="https://github.com/Lruihao" title="GitHub &rarr; https://github.com/Lruihao" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-github"></i></a> </span><span class="links-of-author-item"><a href="https://blog.csdn.net/qq_39520417" title="CSDN &rarr; https://blog.csdn.net/qq_39520417" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-contao"></i></a> </span><span class="links-of-author-item"><a href="https://weibo.com/liahao" title="微博 &rarr; https://weibo.com/liahao" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-weibo"></i></a> </span><span class="links-of-author-item"><a href="/images/qq.jpg" title="QQ &rarr; /images/qq.jpg"><i class="fa fa-fw fa-qq"></i></a> </span><span class="links-of-author-item"><a href="mailto:1074627678@qq.com" title="E-Mail &rarr; mailto:1074627678@qq.com" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-envelope"></i></a></span></div><div class="cc-license motion-element" itemprop="license"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="external nofollow noopener noreferrer" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a></div><div class="links-of-blogroll motion-element links-of-blogroll-inline"><div class="links-of-blogroll-title"><i class="fa fa-fw fa-globe"></i> 书签</div><ul class="links-of-blogroll-list"><li class="links-of-blogroll-item"><a href="/docs/donators/" title="/docs/donators/">赞助记录</a>&ensp;</li><li class="links-of-blogroll-item"><a href="/docs/friends/" title="/docs/friends/">友情链接</a>&ensp;</li><li class="links-of-blogroll-item"><a href="/posts/links.html" title="/posts/links.html">收藏夹</a>&ensp;</li><li class="links-of-blogroll-item"><a href="/posts/font-mmt.html" title="/posts/font-mmt.html">MMT</a>&ensp;</li><li class="links-of-blogroll-item"><a href="http://md.lruihao.cn" title="http://md.lruihao.cn" rel="external nofollow noopener noreferrer" target="_blank">WXMD</a>&ensp;</li><li class="links-of-blogroll-item"><a href="/posts/webbiji.html" title="/posts/webbiji.html">WEB</a>&ensp;</li></ul></div></div></div><div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active"><div class="post-toc"><div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#介绍"><span class="nav-number">1.</span> <span class="nav-text">介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#下载"><span class="nav-number">2.</span> <span class="nav-text">下载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#部分源码"><span class="nav-number">3.</span> <span class="nav-text">部分源码</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#检测更新"><span class="nav-number">3.1.</span> <span class="nav-text">检测更新</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#方向锁定"><span class="nav-number">3.2.</span> <span class="nav-text">方向锁定</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#程序启动事件"><span class="nav-number">3.3.</span> <span class="nav-text">程序启动事件</span></a></li></ol></li></ol></div></div></div></div></aside></div></main><footer id="footer" class="footer"><div class="footer-inner"><div class="copyright">Copyright &copy; 2018 – <span itemprop="copyrightYear">2020</span> <span class="with-love" id="animate"><i class="fa fa-heartbeat"></i> </span><span class="author" itemprop="copyrightHolder">LRH.&ensp;</span> <span title="博客总字数"><i class="fa fa-edit"></i>&ensp;<span class="post-count">115.7k</span>字</span></div><div class="busuanzi-count"><script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span class="post-meta-item-icon"><i class="fa fa-user"></i> </span><span class="site-uv" title="总访客量"><span class="busuanzi-value" id="busuanzi_value_site_uv"><i class="fa fa-spinner fa-spin"></i></span>&thinsp;人次 </span><span class="post-meta-divider">|</span> <span class="run-times" title="网站运行时间">载入天数时分秒...</span> <span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-eye"></i> </span><span class="site-pv" title="总访问量"><span class="busuanzi-value" id="busuanzi_value_site_pv"><i class="fa fa-spinner fa-spin"></i></span>&thinsp;次</span></div><div class="weixin-box"><div class="weixin-menu"><div class="weixin-hover"><div class="weixin-description">微信扫一扫，订阅本博客</div></div></div></div><div class="beian" style="display:inline-block;height:20px;line-height:20px"><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43030402000254" rel="external nofollow noopener noreferrer"><img src="/images/gov.png" style="float:left" alt="公安">湘公网安备43030402000254号</a> <span class="post-meta-divider" style="color:#555">|</span> <span><a href="http://www.beian.miit.gov.cn" target="_blank" rel="external nofollow noopener noreferrer">湘ICP备18020535号</a></span></div></div></footer><div class="back-to-top"><i class="fa fa-arrow-up"></i> <span id="scrollpercent"><span>0</span>%</span></div></div><script type="text/javascript">"[object Function]"!==Object.prototype.toString.call(window.Promise)&&(window.Promise=null)</script><script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script><script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script><script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script><script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js"></script><script type="text/javascript" src="/lib/reading_progress/reading_progress.js"></script><script type="text/javascript" src="/js/src/utils.js?v=6.7.0"></script><script type="text/javascript" src="/js/src/motion.js?v=6.7.0"></script><script type="text/javascript" src="/js/src/affix.js?v=6.7.0"></script><script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.7.0"></script><script type="text/javascript" src="/js/src/scrollspy.js?v=6.7.0"></script><script type="text/javascript" src="/js/src/post-details.js?v=6.7.0"></script><script type="text/javascript" src="/js/src/bootstrap.js?v=6.7.0"></script><script>$(".highlight").each(function(t,e){var n=$("<div>").addClass("highlight-wrap");$(e).after(n),n.append($("<button>").addClass("copy-btn").append("复制").on("click",function(t){var e=$(this).parent().find(".code").find(".line").map(function(t,e){return $(e).text()}).toArray().join("\n"),n=document.createElement("textarea");document.body.appendChild(n),n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.value=e,n.select(),n.focus();var o=document.execCommand("copy");document.body.removeChild(n),o?$(this).text("复制成功"):$(this).text("复制失败"),$(this).blur()})).on("mouseleave",function(t){var e=$(this).find(".copy-btn");setTimeout(function(){e.text("复制")},300)}).append(e)})</script><script>$("body").find("pre.mermaid").length&&$.ajax({type:"GET",url:"//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js",dataType:"script",cache:!0,success:function(){mermaid.initialize({theme:"forest",logLevel:3,flowchart:{curve:"linear"},gantt:{axisFormat:"%m/%d/%Y"},sequence:{actorMargin:50}})}})</script><script>function createTime(){var e=new Date,t=new Date("05/28/2018 20:01:01"),n=(e-t)/1e3,i=Math.floor(n/60/60/24),r=Math.floor(n/60/60-24*i),h=Math.floor(n/60-1440*i-60*r),a=Math.floor((e-t)/1e3-86400*i-3600*r-60*h);1===String(r).length&&(r="0"+r),1===String(h).length&&(h="0"+h),1===String(a).length&&(a="0"+a),document.querySelector(".run-times").innerHTML=i+"&thinsp;天&thinsp;"+r+"&thinsp;时&thinsp;"+h+"&thinsp;分&thinsp;"+a+"&thinsp;秒"}if(document.hidden)clearInterval(siteTime);else var siteTime=setInterval("createTime()",500)</script><script type="text/javascript" src="/js/src/console.js"></script><script async type="text/javascript" src="/js/src/night.js"></script><div class="cover"></div><script async type="text/javascript" src="/js/src/crash-cheat.js"></script><script src="/js/src/activate-power-mode.js"></script><script>POWERMODE.colorful=!0,POWERMODE.shake=!1,document.body.addEventListener("input",POWERMODE)</script><script type="text/javascript" src="/js/src/love.js"></script><script type="text/javascript" src="/js/src/link-card.js" defer></script><script type="text/javascript" src="/js/src/pageQRcode.js" defer></script><script src="//cdn1.lncld.net/static/js/3.11.1/av-min.js"></script><script src="//unpkg.com/valine/dist/Valine.min.js"></script><script>var GUEST=["nick","mail","link"],guest="nick,mail,link";guest=guest.split(",").filter(function(e){return-1<GUEST.indexOf(e)}),new Valine({el:"#comments",verify:!1,notify:!1,appId:"7HwTRT0Q0Tfrat6ugrT6P67c-gzGzoHsz",appKey:"mhTY1kuUmviCtQwkwOASfsfD",placeholder:"ヾﾉ≧∀≦)o~ 有事请留言！\n评论功能以邮件作为通知方式！\n如有必要请填写正确邮箱！",avatar:"wavatar",meta:guest,pageSize:"10",visitor:!0,lang:"zh-cn"})</script><script type="text/javascript">// Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });</script><script>!function(){var t=document.createElement("script"),e=window.location.protocol.split(":")[0];t.src="https"===e?"https://zz.bdstatic.com/linksubmit/push.js":"http://push.zhanzhang.baidu.com/push.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(t,s)}()</script><script src="/lib/pangu/dist/pangu.min.js?v=3.3"></script><script type="text/javascript">pangu.spacingPage()</script><script src="/lib/bookmark/bookmark.min.js?v=1.0"></script><script type="text/javascript">bookmark.scrollToMark("manual","#更多")</script><script>!function(e){var r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]"));function t(){for(var c=0;c<r.length;c++)t=r[c],void 0,0<=(n=t.getBoundingClientRect()).top&&0<=n.left&&n.top<=(e.innerHeight||document.documentElement.clientHeight)&&function(){var t,n,e,i,o=r[c];t=o,n=function(){r=r.filter(function(t){return o!==t})},e=new Image,i=t.getAttribute("data-original"),e.onload=function(){t.src=i,n&&n()},e.src=i}();var t,n}t(),e.addEventListener("scroll",function(){!function(t,n){clearTimeout(t.tId),t.tId=setTimeout(function(){t.call(n)},500)}(t,e)})}(this);</script></body></html>